<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  
</body>
<script>

let a = [1,2,3 ,45,45]

function removeDuplicatedItem (obj) { // 对象去重
  let type = checkType(obj)
  console.log(type)
  console.log(...obj)
  if (type === 'Array') {
    return Array.from(new Set(obj))
  } else if (type === 'Object') {
    return Array.from(new Set(obj))
  }
}

function checkType (obj) { // 检查类型
  let type = ''
  switch (Object.prototype.toString.call(obj)) {
    case '[object Object]':
      type = 'Object'
      break
    case '[object Array]':
      type = 'Array'
      break
    case '[object Function]':
      type = 'Function'
      break
    case '[object String]':
      type = 'String'
      break
    case '[object Number]':
      type = 'Number'
      break
    case '[object Boolean]':
      type = 'Boolean'
      break
    case '[object Undefined]':
      type = 'Undefined'
      break
    case '[object Null]':
      type = 'Null'
      break
  }
  return type
}
console.log(removeDuplicatedItem(a))
</script>
</html>